package com.sainan114.pipelinestudy;

import com.sainan114.pipelinestudy.strategy.AbstractStrategy;
import com.sainan114.pipelinestudy.util.LogUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.Logger;


import java.util.HashMap;
import java.util.Map;

/**
 * @author lgb
 * @Date: 2021/7/9
 */
public class StrategyFactory {


    private final static Map<String, AbstractStrategy> beanMap = new HashMap<>();

    /**
     * 注册bean
     */
    public static void registerBean(String key, AbstractStrategy abstractStrategy) {
        if (StringUtils.isBlank(key)) {
            return;
        }
        if (abstractStrategy == null) {
            return;
        }
        beanMap.put(key, abstractStrategy);
    }

    /**
     * 获取bean
     */
    public static AbstractStrategy getBean (String key) {
        return beanMap.get(key);
    }
}
